package cn.jbolt.ec.spreader;

import cn.jbolt.base.JBoltBaseController;
import com.alibaba.fastjson.JSONObject;
import com.jfinal.aop.Inject;

public class EcSpreaderController extends JBoltBaseController {

    @Inject
    SpreaderService spreaderService;

    /**
     * 申请成为分销商
     * @param openSession
     * @param name
     * @param mobile
     * @param why_apply
     */
    public void applicant_spreader(String openSession,String name,String mobile,String why_apply){
        JSONObject jo=new JSONObject();
        if (null!=getSessionAttr(openSession+"_member_id")){
            JSONObject jo1=new JSONObject();
            if (spreaderService.applicant_spreader(getSessionAttr(openSession+"_member_id"), name, mobile, why_apply)){
                jo1.put("code",0);
                jo1.put("msg","申请成功");
                renderJson(jo1);
            }else {
                jo1.put("code",1);
                jo1.put("msg","请勿重复申请");
                renderJson(jo1);
            }
        }else {
            jo.put("ok",1001);
            jo.put("msg","无效Session");
            renderJson(jo);
        }


    }

    /**
     * 获取分销商下线
     * @param openSession
     */
    public void spreader_friends(String openSession){
        JSONObject jo=new JSONObject();
        if (null!=getSessionAttr(openSession+"_member_id")){
            renderJson(spreaderService.spreader_friends(getSessionAttr(openSession+"_member_id")));
        }else {
            jo.put("ok",1001);
            jo.put("msg","无效Session");
            renderJson(jo);
        }

    }


}
